﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Data.SqlClient;
using System.Configuration;

/// <summary>
/// Summary description for D_Referer
/// </summary>
namespace Bestlife.ERP.DataAccess
{
    public class D_Referer
    {
        public D_Referer()
        {
            //
            // TODO: Add constructor logic here
            //
        }
        public static String super(string Super_Distribuor)
        {
            string title = "";
            string name = "";
            string error = "";
            SqlConnection conn_new = new SqlConnection();
            try
            {
                String connStr = ConfigurationManager.ConnectionStrings["BestlifeDBConnectionString"].ConnectionString;
                Bestlife.ERP.DataAccess.Connection.connect(connStr);//connection string pass to connection class

                String Ssql = "SELECT [Giv_Name],[Title] FROM [Tbl_Distributor] where Dis_ID='" + Super_Distribuor + "'";
                //SqlDataReader ldr = Bestlife.ERP.DataAccess.clsCon.ReadTable(Ssql);

                SqlDataReader rdR;
                rdR = Connection.ReadTable(Ssql);



                if (rdR.Read())
                {
                    name = rdR["Giv_Name"].ToString();
                    title = rdR["Title"].ToString();

                }
                else
                {
                    error = "Sorry, this does not seem to be a valid Referrer ID.";
                }
            }
            catch (Exception)
            {
                // Console.WriteLine(exx);
            }
            Connection.con.Close();
            return title+name+error;
            
        }

    }
}